package com.oxygen.pt.mapper;

import com.oxygen.pt.pojo.entity.TreatmentStatistics;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;

@Mapper
public interface TreatmentStatisticsMapper {
    // 插入每日记录（忽略重复）
    @Insert("INSERT INTO treatment_statistics (date, pending_assignment, assigned, in_treatment, completed, create_time, update_time) " +
            "VALUES (#{date}, #{pendingAssignment}, #{assigned}, #{inTreatment}, #{completed}, #{createTime}, #{updateTime})")
    void insertTreatmentStatistics(TreatmentStatistics treatmentStatistics);

    // 根据日期更新数据
    @Update("UPDATE treatment_statistics SET " +
            "pending_assignment = #{pendingAssignment}, " +
            "assigned = #{assigned}, " +
            "in_treatment = #{inTreatment}, " +
            "completed = #{completed} " +
            "WHERE date = #{date}")
    int updateByDate(TreatmentStatistics entity);

    //根据日期查询当日的治疗记录
    @Select("SELECT * FROM treatment_statistics WHERE date = #{date}")
    TreatmentStatistics selectByDate(@Param("date") LocalDate date);
}